package com.xuliugen.rpc.proxy;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * Netty返回数据的Handler处理对象
 * @author xuliugen
 * @date 2018/6/6
 */
public class RpcProxyHandler extends ChannelInboundHandlerAdapter {

    /**
     * 返回信息包
     */
    private Object response;

    /**
     * 暴露出去返回信息包
     * @return
     */
    public Object getResponse() {
        return response;
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) {
        response = msg;
        System.out.println("接受到返回后的消息内容：" + response);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        System.out.println("处理过程发生异常！");
    }
}
